package qotwReader.parseInput;

import qotwReader.types.*;

public enum Command 
{
    download(DownloadAction.values(), "Which question(s) should be downloaded."),
    output(EbookType.values(), "The ebook format the question should be saved as.\n Epub works quite well."),
    reader(ReaderType.values(), "The ebook reader that the ebooks should be tailored for.\n Defaultreader should be fine if you're unsure."),
    calibredir("\"C:\\Program Files\\Calibre2\".", "The directory in which Calibre has been installed."),
    ;
    
    private static final String commandDesignator = "-";
    
    final private Type[] validArgs;
    final private String description;
    final private String exampleArg;
    
    private Command(Type[] validArgs, String desciption)
    {
        this.validArgs = validArgs;
        this.description = desciption;
        this.exampleArg = validArgs[0].toString();
    }
    
    private Command(String exampleArg, String description)
    {
        validArgs = null;
        this.description = description;
        this.exampleArg = exampleArg;
    }
    
    public String getDescription() { return this.description; }
    public String getCommandString() { return commandDesignator + this.toString(); }
        
    public String[] getValidArgs()
    {
        
        if (validArgs == null)
        {
            String[] exampleArgInArray = { exampleArg };
            return exampleArgInArray;
        }
        else
        {
            String[] argStrings = new String[validArgs.length];
            for (int i = 0; i < validArgs.length; i++)
                argStrings[i] = validArgs[i].toString();
            return argStrings;
        }
    }
    
    public static String getAvailCmdsString()
    {
        String availCmds = "";
        for (Command c : Command.values())
            availCmds += c.getCommandString() + "   ";
        return availCmds;
    }
    
    public String getValidArgsString()
    {
        String validArgs = "";
        for (String s : getValidArgs())
            validArgs += s + "  ";
        
        return validArgs;
    }
}